library(ggplot2)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ tibble  3.1.0     ✓ purrr   0.3.4
## ✓ tidyr   1.1.3     ✓ stringr 1.4.0
## ✓ readr   1.4.0     ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(arsenal)
library(data.table)
## 
## Attaching package: 'data.table'
## The following object is masked from 'package:purrr':
## 
##     transpose
## The following objects are masked from 'package:dplyr':
## 
##     between, first, last
library(expss)
## 
## Attaching package: 'expss'
## The following objects are masked from 'package:data.table':
## 
##     copy, like
## The following objects are masked from 'package:stringr':
## 
##     fixed, regex
## The following objects are masked from 'package:purrr':
## 
##     keep, modify, modify_if, transpose, when
## The following objects are masked from 'package:tidyr':
## 
##     contains, nest
## The following objects are masked from 'package:dplyr':
## 
##     between, compute, contains, first, last, na_if, recode, vars
## The following object is masked from 'package:ggplot2':
## 
##     vars
#ideas, stratify by what do you consider a good nights sleep
#additive index according to behaviors 
#regression models for the outcome.

#Positive quality of sleep - 
#Consistent wake up 
#Greater than 7 hrs to 9 hrs --> stratify #for sure USE THIS AND ONE OR THE OTHER
  #Agreement questions Q44
  #Current bedtime routines
  #Current lifestyle habits
  #Employment and children
sleephygiene <- read_csv("/Users/Ivanics/Desktop/SPH/3rd term/Health Communication Programs I/Stats/Sleep Hygiene Survey_March 12, 2021_15.56.csv")
## Warning: Duplicated column names deduplicated: 'Q37' => 'Q37_1' [64]
## 
## ── Column specification ────────────────────────────────────────────────────────
## cols(
##   .default = col_character()
## )
## ℹ Use `spec()` for the full column specifications.
sleephygiene$StartDate <- lubridate::ymd_hms(sleephygiene$StartDate)
## Warning: 2 failed to parse.
#Filter to include only responses beyond this time
sleephygiene <- sleephygiene %>% filter(StartDate >= "2021-03-09 14:00:00")

#Select out the variables we need
sleephygiene <- sleephygiene %>% select(Progress, `Duration (in seconds)`, Finished, LocationLatitude, LocationLongitude, DistributionChannel, UserLanguage, Q1, Q2, Q3, Q2_5_TEXT, Q4, Q5, Q6, Q37, Q38, Q39, Q7, Q8, Q8_3_TEXT, Q10, Q11, Q9, Q13, Q13, Q14_10, Q14_11, Q15, Q16_4, Q16_5, Q49, Q42, Q42_10_TEXT, Q19, Q17_NPS_GROUP, Q17, Q36, Q36_6_TEXT, Q18, Q20, Q9, Q13, Q14_10, Q14_11, Q15, Q16_4, Q16_5, Q49, Q42, Q42_10_TEXT, Q19, Q12_1, Q17_NPS_GROUP, Q17, Q36, Q36_6_TEXT, Q18, Q20, Q44_1, Q44_2, Q44_3, Q44_4, Q44_5, Q44_6, Q44_7, Q44_8, Q44_9, Q59_1, Q59_2, Q59_2, Q59_3, Q59_4, Q37_1, Q33, Q50_1, Q50_2, Q50_3, Q50_4, Q50_5, Q50_6, Q50_7, Q53_1, Q53_2, Q53_3, Q53_4, Q53_5, Q48, Q48_5_TEXT, Q52, `Q5 - Topics`, `Q5 - Parent Topics`)

sleephygiene <- rowid_to_column(sleephygiene, "ID")
#Variable 14
sleephygiene$Q14_10_new_hours <- sub(":.*", "", sleephygiene$Q14_10)
sleephygiene$Q14_10_new_hours <- ifelse(nchar(sleephygiene$Q14_10_new_hours)==3, (str_extract(sleephygiene$Q14_10_new_hours, "^\\d{1}")), sleephygiene$Q14_10_new_hours)
sleephygiene$Q14_10_new_hours <- ifelse(nchar(sleephygiene$Q14_10_new_hours)==4, (str_extract(sleephygiene$Q14_10_new_hours, "^\\d{2}")), sleephygiene$Q14_10_new_hours)
sleephygiene$Q14_10_new_minutes <- str_extract(sleephygiene$Q14_10, "(?<=:)[0-9]*")
sleephygiene$Q14_10_new_minutes <- ifelse(is.na(sleephygiene$Q14_10_new_minutes) & !is.na(sleephygiene$Q14_10_new_hours), "00", sleephygiene$Q14_10_new_minutes)
sleephygiene$Q14_10_new_hours <- as.numeric(sleephygiene$Q14_10_new_hours)
## Warning: NAs introduced by coercion
sleephygiene$Q14_10_new_minutes <- ifelse(grepl("[0-9]+", sleephygiene$Q14_11), sleephygiene$Q14_11, sleephygiene$Q14_10_new_minutes) 
sleephygiene$Q14_10_new_hours <- ifelse(grepl("[pP][mM]", sleephygiene$Q14_11), sleephygiene$Q14_10_new_hours+12, sleephygiene$Q14_10_new_hours)
sleephygiene$Q14_10_new_hours <- as.character(sleephygiene$Q14_10_new_hours)

#Variable 16
#Put in a semicolon
sleephygiene$Q16_4_new_hours <- sub(":.*", "", sleephygiene$Q16_4)
#If the length of the string is 3 extract the first digit
sleephygiene$Q16_4_new_hours <- ifelse(nchar(sleephygiene$Q16_4_new_hours)==3, (str_extract(sleephygiene$Q16_4_new_hours, "^\\d{1}")), sleephygiene$Q16_4_new_hours)
#if the length of the string is 4 extract the second digit
sleephygiene$Q16_4_new_hours <- ifelse(nchar(sleephygiene$Q16_4_new_hours)==4, (str_extract(sleephygiene$Q16_4_new_hours, "^\\d{2}")), sleephygiene$Q16_4_new_hours)
#if theres a number in the q16_5 variable put it in minutes
sleephygiene$Q16_4_new_minutes <- str_extract(sleephygiene$Q16_5, "(?<=:)[0-9]*")
#if the q16_4 minute variable has missing values replace them with 00
sleephygiene$Q16_4_new_minutes <- ifelse(is.na(sleephygiene$Q16_4_new_minutes) & !is.na(sleephygiene$Q16_4_new_hours), "00", sleephygiene$Q16_4_new_minutes)
#If there is a number in q16_5 put that in minutes
sleephygiene$Q16_4_new_minutes <- ifelse(grepl("[0-9]+", sleephygiene$Q16_5), sleephygiene$Q16_5, sleephygiene$Q16_4_new_minutes) 
#if there is a ncar length of 5 in q16_4 (suggesting a format like 16:00) take the 4 and 5 digits and put that in minutes
sleephygiene$Q16_4_new_minutes <- ifelse(nchar(sleephygiene$Q16_4)==5, substr(sleephygiene$Q16_4, 4, 5), sleephygiene$Q16_4_new_minutes)
#make the hour variable a numeric
sleephygiene$Q16_4_new_hours <- as.numeric(sleephygiene$Q16_4_new_hours)
#if there is a pm add 12 hours in q16_5 to the hours
sleephygiene$Q16_4_new_hours <- ifelse(grepl("[pP]", sleephygiene$Q16_5), sleephygiene$Q16_4_new_hours+12, sleephygiene$Q16_4_new_hours)
#if there is a 12 in q16_4 and am has been noted also add 12 hours
sleephygiene$Q16_4_new_hours <- ifelse((grepl("[12]", sleephygiene$Q16_4) & grepl("[aA][mM]", sleephygiene$Q16_5)), sleephygiene$Q16_4_new_hours+12, sleephygiene$Q16_4_new_hours)
#Make the hours a character now in preparation to convert to posixct 
sleephygiene$Q16_4_new_hours <- as.character(sleephygiene$Q16_4_new_hours)

sleephygiene <- sleephygiene %>% mutate(Q16_4_new_hours = case_when(
  Q16_4_new_hours == "24" ~ "00",
  Q16_4_new_hours == "13" & grepl("[aA]", Q16_5) ~ "01",
  Q16_4_new_hours == "7" ~ "07",
  TRUE ~ Q16_4_new_hours
))

#Create a sleeptime and wakeup variable
sleephygiene <- sleephygiene %>% 
  mutate(Q14_wakeuptime = 
           case_when(!is.na(Q14_10_new_hours) ~ paste0(Q14_10_new_hours,":",Q14_10_new_minutes),
                     TRUE ~ NA_character_)) %>%
  mutate(Q16_sleeptime =
           case_when(!is.na(Q16_4_new_hours) ~ paste0(Q16_4_new_hours,":",Q16_4_new_minutes),
                     TRUE ~ NA_character_))

sleephygiene$Q14_wakeuptime <- as.POSIXct(sleephygiene$Q14_wakeuptime, format="%H:%M")
#sleephygiene$Q16_sleeptime <- as.POSIXct(sleephygiene$Q16_sleeptime, format="%H:%M")

#sleephygiene %>% select(Q14_10_new_hours, Q14_10_new_minutes, Q14_11, Q14_wakeuptime, Q14_10) %>% View()
#General factor recoding
sleephygiene <- sleephygiene %>% mutate(
  Q1_consent = factor(Q1)) %>%
  mutate(Q2_program = factor(Q2)) %>%
  mutate(Q3_role = factor(Q3)) %>%
  mutate(Q4_gender = factor(Q4)) %>%
  mutate(Q5_age = as.numeric(Q5)) %>%
  mutate(Q6_numberinhousehold = as.numeric(Q6)) %>%
  mutate(Q37_employed = factor(Q37)) %>%
  mutate(Q38_wfh = factor(Q38)) %>%
  mutate(Q39_dayornight = factor(Q39)) %>%
  mutate(Q7_children = factor(Q7)) %>%
  mutate(Q8_diagnosis = factor(Q8)) %>%
  mutate(Q10_workdayhoursofsleep = as.numeric(Q10)) %>%
  mutate(Q11_weekendhoursofsleep = as.numeric(Q11)) %>%
  mutate(Q9_howoftensleepy = factor(Q9)) %>%
  mutate(Q13_consistentwakeup = factor(Q13)) %>%
  mutate(Q15_consistentbedtimeonweekdays = factor(Q15)) %>%
  mutate(Q49_sleepqualitychangecovid = factor(Q49)) %>%
  mutate(Q18_howoftenpracticemindfullness = factor(Q18)) %>%
  mutate(Q44_1_thingsidointhelasthourbeforesleepaffectthequalityofmysleep = factor(Q44_1)) %>%
  mutate(Q44_2_gettingagoodnightssleepisimportantome = factor(Q44_2)) %>%
  mutate(Q44_3_mostofmyfriendshaveahealthysleeproutine = factor(Q44_3)) %>%
  mutate(Q44_4_lackofsleepaffectsmyacademicperformance = factor(Q44_4)) %>%
  mutate(Q44_5_havingaregularsleeproutineimprovesmentalclariy = factor(Q44_5)) %>%
  mutate(Q44_6_ifeelpositiveaboutthequalityofmysleep = factor(Q44_6)) %>%
  mutate(Q44_7_ithinkcuttingoutscreenuseonehourbeforesleepleadstobettersleep = factor(Q44_7)) %>%
  mutate(Q44_8_ithinkingworkingoutregularlyleadstobettersleep = factor(Q44_8)) %>%
  mutate(Q44_9_ithinkmeditatingbeforesleephelpsquality = factor(Q44_9)) %>%
  mutate(Q59_1_icanmaintainhealthysleephabits = factor(Q59_1)) %>%
  mutate(Q59_2_icancutoutscreenuseonehourbeforesleep = factor(Q59_2)) %>%
  mutate(Q59_3_icanworkoutregularly = factor(Q59_3)) %>%
  mutate(Q59_4_icanmediatebeforebed = factor(Q59_4)) %>%
  mutate(Q37_whatdoyouconsideragoodnightssleep = factor(Q37_1))
## Warning in mask$eval_all_mutate(quo): NAs introduced by coercion

## Warning in mask$eval_all_mutate(quo): NAs introduced by coercion

## Warning in mask$eval_all_mutate(quo): NAs introduced by coercion

## Warning in mask$eval_all_mutate(quo): NAs introduced by coercion
#Q19
sleephygiene$Q19_howmanyhourssdidyouuseascreen <- str_extract(sleephygiene$Q19, '\\d+')

#Q12
sleephygiene$Q12_1_howmanynightsusescreen <- as.numeric(sleephygiene$Q12_1)

#Q17
sleephygiene$Q17_stressedaboutschool <- as.numeric(sleephygiene$Q17) 

#Q33
#Come back to this one because some are given as a range
sleephygiene$Q33_whatisthrecommendednumbersofhoursofsleep <- str_extract(sleephygiene$Q33, '\\d+')
sleephygiene$Q33_whatisthrecommendednumbersofhoursofsleep <- as.numeric(sleephygiene$Q33_whatisthrecommendednumbersofhoursofsleep)

#Q50
sleephygiene <- sleephygiene %>% 
  mutate(Q50_1_energyfordailyacitivites = as.numeric(Q50_1)) %>%
  mutate(Q50_2_attractivness = as.numeric(Q50_2)) %>%
  mutate(Q50_3_productivity = as.numeric(Q50_3)) %>%
  mutate(Q50_4_accomplishmentofotherdailygoals = as.numeric(Q50_4)) %>%
  mutate(Q50_5_mentalandemotionalwellbeing = as.numeric(Q50_5)) %>%
  mutate(Q50_6_fosteringmaintaingrelationships = as.numeric(Q50_6)) %>%
  mutate(Q50_7_caringforchildren = as.numeric(Q50_7))

#Q53
sleephygiene <- sleephygiene %>% 
  mutate(Q53_1_getoutsidefor10mininthemorning = as.numeric(Q53_1)) %>%
  mutate(Q53_2_exerciseduringtheday = as.numeric(Q53_2)) %>%
  mutate(Q53_3_doingabreathingexercisebeforesleep = as.numeric(Q53_3)) %>%
  mutate(Q53_4_notusescreens = as.numeric(Q53_4)) %>%
  mutate(Q53_5_listeningtoacalmingaudiobookorpodcast = as.numeric(Q53_5))
#Q42
resp.split_42 <- strsplit(sleephygiene$Q42, ",")
lev <- unique(unlist(resp.split_42))
sleephygiene<- with(sleephygiene, data.frame(sleephygiene, t(sapply(resp.split_42, function(x) table(factor(x, levels=lev))))))

sleephygiene <- sleephygiene %>%
    mutate(bedtimeroutine = case_when(
    Washing.my.face == 1 ~ "Washing my face",
    Brushing.teeth == 1 ~ "Brushing teeth",
    Showering == 1 ~ "Showering",
    Reading == 1 ~ "Reading",
    Journaling == 1 ~ "Journaling",
    Meditating == 1 ~ "Meditating",
    Watching.TV == 1 ~ "Watching TV",
    Phone.Usage == 1 ~ "Phone usage",
    Listening.to.Music == 1 ~ "Listening to music",
    Other == 1 ~ "Other"))

#Q36
resp.split_36 <- strsplit(sleephygiene$Q36, ",")
lev <- unique(unlist(resp.split_36))
sleephygiene<- with(sleephygiene, data.frame(sleephygiene, t(sapply(resp.split_36, function(x) table(factor(x, levels=lev))))))

sleephygiene <- sleephygiene %>%
    mutate(cantsleepfeeling = case_when(
    Guilty == 1 ~ "Guilty",
    Angry == 1 ~ "Angry",
    Frustrated == 1 ~ "Frustrated",
    Sad == 1 ~ "Sad",
    Stressed == 1 ~ "Stressed",
    None.of.the.above == 1 ~ "None of the above",
    Other.1 == 1 ~ "Other"))

#Q20
resp.split_20 <- strsplit(sleephygiene$Q20, ",")
lev <- unique(unlist(resp.split_20))
sleephygiene<- with(sleephygiene, data.frame(sleephygiene, t(sapply(resp.split_20, function(x) table(factor(x, levels=lev))))))

sleephygiene <- sleephygiene %>%
    mutate(behaviors = case_when(
    Cigarette.Smoking == 1 ~ "Cigarette smoking",
    Alcohol.Consumption == 1 ~ "Alcohol Consumption",
    Exercise == 1 ~ "Exercise",
    Social.Media.Use == 1 ~ "Social Media Use",
    Daytime.Napping == 1 ~ "Daytime napping",
    Drinking.Caffeinated.beverages == 1 ~ "Drinking Caffeinated beverages",
    Using.Sleep.Aids..ex..melatonin == 1 ~ "Using Sleep Aids ex. melatonin"))

#48
resp.split_48 <- strsplit(sleephygiene$Q48, ",")
lev <- unique(unlist(resp.split_48))
sleephygiene<- with(sleephygiene, data.frame(sleephygiene, t(sapply(resp.split_48, function(x) table(factor(x, levels=lev))))))

sleephygiene <- sleephygiene %>%
    mutate(information = case_when(
    Health.care.professional == 1 ~ "Health care professional",
    Social.media == 1 ~ "Social media",
    Other.online.source == 1 ~ "Other online source",
    News.sources == 1 ~ "News sources",
    Friends == 1 ~ "Friends",
    University.wellbeing.resources..Office.of.Wellness.and.Health.Promotion == 1 ~ "University wellbeing resources"))

Plots for wakeup and sleep times

library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
wakeup <- ggplot(data=sleephygiene, aes(y=Q14_wakeuptime,x=ID)) + 
  geom_point(size=4, color="darkblue") +
  theme_test() +
  theme(text = element_text(size=32), plot.title = element_text(hjust = 0.5)) +
  labs(title="Wake up times of participants", x="Unique participant", y="Wake up time")
  #+
  #xlim(as.POSIXct(c("2021-03-10 05:00:00", "2021-03-10 12:00:00")))
ggplotly(wakeup)
#Plot for sleeptime
sleeptime <- ggplot(data=sleephygiene, aes(y=Q16_sleeptime,x=ID)) + 
   geom_point(size=4, color="darkred") +
  theme_test() +
  theme(text = element_text(size=32), plot.title = element_text(hjust = 0.5)) +
  labs(title="Sleep times of participants", x="Unique participant", y="Sleep time")
ggplotly(sleeptime)
#Tab 1
sleephygiene$Q9_howoftensleepy <- factor(sleephygiene$Q9_howoftensleepy, levels = c("Rarely", "Sometimes", "Very often", "Always"))
sleephygiene$Q13_consistentwakeup <- factor(sleephygiene$Q13_consistentwakeup, levels = c("Rarely", "Sometimes", "Very often", "Always"))
sleephygiene$Q19_howmanyhourssdidyouuseascreen <- factor(sleephygiene$Q19_howmanyhourssdidyouuseascreen, levels = c("0", "1" , "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17"))
sleephygiene$Q18_howoftenpracticemindfullness <- factor(sleephygiene$Q18_howoftenpracticemindfullness, levels = c("Rarely", "Sometimes", "Very often", "Always"))
sleephygiene$Q44_1_thingsidointhelasthourbeforesleepaffectthequalityofmysleep <- factor(sleephygiene$Q44_1_thingsidointhelasthourbeforesleepaffectthequalityofmysleep, levels = c("Strongly disagree", "Somewhat disagree", "Neither agree nor disagree", "Somewhat agree", "Strongly agree"))
sleephygiene$Q44_2_gettingagoodnightssleepisimportantome <- factor(sleephygiene$Q44_2_gettingagoodnightssleepisimportantome, levels = c("Strongly disagree", "Somewhat disagree", "Neither agree nor disagree", "Somewhat agree", "Strongly agree"))
sleephygiene$Q44_3_mostofmyfriendshaveahealthysleeproutine <- factor(sleephygiene$Q44_3_mostofmyfriendshaveahealthysleeproutine, levels = c("Strongly disagree", "Somewhat disagree", "Neither agree nor disagree", "Somewhat agree", "Strongly agree"))
sleephygiene$Q44_4_lackofsleepaffectsmyacademicperformance <- factor(sleephygiene$Q44_4_lackofsleepaffectsmyacademicperformance, levels = c("Strongly disagree", "Somewhat disagree", "Neither agree nor disagree", "Somewhat agree", "Strongly agree"))
sleephygiene$Q44_5_havingaregularsleeproutineimprovesmentalclariy <- factor(sleephygiene$Q44_5_havingaregularsleeproutineimprovesmentalclariy, levels = c("Strongly disagree", "Somewhat disagree", "Neither agree nor disagree", "Somewhat agree", "Strongly agree"))
sleephygiene$Q44_6_ifeelpositiveaboutthequalityofmysleep <- factor(sleephygiene$Q44_6_ifeelpositiveaboutthequalityofmysleep, levels = c("Strongly disagree", "Somewhat disagree", "Neither agree nor disagree", "Somewhat agree", "Strongly agree"))
sleephygiene$Q44_7_ithinkcuttingoutscreenuseonehourbeforesleepleadstobettersleep <- factor(sleephygiene$Q44_7_ithinkcuttingoutscreenuseonehourbeforesleepleadstobettersleep, levels = c("Strongly disagree", "Somewhat disagree", "Neither agree nor disagree", "Somewhat agree", "Strongly agree"))
sleephygiene$Q44_8_ithinkingworkingoutregularlyleadstobettersleep <- factor(sleephygiene$Q44_8_ithinkingworkingoutregularlyleadstobettersleep, levels = c("Strongly disagree", "Somewhat disagree", "Neither agree nor disagree", "Somewhat agree", "Strongly agree"))
sleephygiene$Q44_9_ithinkmeditatingbeforesleephelpsquality <- factor(sleephygiene$Q44_9_ithinkmeditatingbeforesleephelpsquality, levels = c("Strongly disagree", "Somewhat disagree", "Neither agree nor disagree", "Somewhat agree", "Strongly agree"))
sleephygiene$Q59_1_icanmaintainhealthysleephabits <- factor(sleephygiene$Q59_1_icanmaintainhealthysleephabits, levels = c("Not at all confident", "Slightly confident", "Somewhat confident", "Pretty confident", "Extremely confident"))
sleephygiene$Q59_2_icancutoutscreenuseonehourbeforesleep <- factor(sleephygiene$Q59_2_icancutoutscreenuseonehourbeforesleep, levels = c("Not at all confident", "Slightly confident", "Somewhat confident", "Pretty confident", "Extremely confident"))
sleephygiene$Q59_3_icanworkoutregularly <- factor(sleephygiene$Q59_3_icanworkoutregularly, levels = c("Not at all confident", "Slightly confident", "Somewhat confident", "Pretty confident", "Extremely confident"))
sleephygiene$Q59_4_icanmediatebeforebed <- factor(sleephygiene$Q59_4_icanmediatebeforebed, levels = c("Not at all confident", "Slightly confident", "Somewhat confident", "Pretty confident", "Extremely confident"))

library(expss)
sleephygiene = apply_labels(sleephygiene,
                      Q3_role = "What is your role at Bloomberg",
                      Q4_gender = "What gender do you identify as?",
                      Q5_age = "How old are you?",
                      Q6_numberinhousehold = "How many people live in your household, including yourself?",
                      Q37_employed = "Are you currently employed outside of your education program?",
                      Q8_diagnosis = "Have you ever been diagnosed with any of the following sleep disorders?",
                      Q10_workdayhoursofsleep = "During the past 5 workdays, how many hours of sleep did you get per night on average?",
                      Q11_weekendhoursofsleep = "During the past weekend, how many hours of sleep did you get per night on average? ",
                      Q13_consistentwakeup = "Do you have a consistent time you wake up on weekdays?",
                      Q15_consistentbedtimeonweekdays = "Do you have a consistent time you wake up on weekdays?",
                      Q9_howoftensleepy = "How often do you feel sleepy during the day?",
                      Q2_program = "What is your current program at Bloomberg?",
                      Q38_wfh = "Do you work from home?",
                      Q39_dayornight = "Do you work day or night shifts?",
                      Q49_sleepqualitychangecovid = "Has your sleep quality changed due to the COVID-19 pandemic? ",
                      bedtimeroutine = "My bedtime routine includes:",
                      Q19_howmanyhourssdidyouuseascreen = "How many hours per day do you typically use a screen? (i.e. cell phone, tablet, computer, television)",
                      Q12_1_howmanynightsusescreen = "In the past week, how many nights did you use screens (i.e. cell phone, tablet, computer, television) within 1 hour before bed?",
                      Q17_stressedaboutschool = "How stressed do you currently feel about school?",
                      cantsleepfeeling = "When you can't sleep do you feel",
                      Q18_howoftenpracticemindfullness = "How often do you practice mindfulness techniques? (i.e. breathing exercises, meditation, etc.,)",
                      behaviors = "Which of the following behaviors do you participate in? ",
                      Q44_1_thingsidointhelasthourbeforesleepaffectthequalityofmysleep = "The things I do in the last hour before bed affect the quality of my sleep.",
                      Q44_2_gettingagoodnightssleepisimportantome = "Getting a good night's sleep is important to me.",
                      Q44_3_mostofmyfriendshaveahealthysleeproutine = "Most of my friends have a healthy sleep routine.",
                      Q44_4_lackofsleepaffectsmyacademicperformance = "Lack of sleep affects my academic performance.",
                      Q44_5_havingaregularsleeproutineimprovesmentalclariy = "Having a regular sleep routine improves mental clarity/sharpness.",
                      Q44_6_ifeelpositiveaboutthequalityofmysleep = "I feel positive about the quality of my sleep.",
                      Q44_7_ithinkcuttingoutscreenuseonehourbeforesleepleadstobettersleep = "I think cutting out screen use 1 hour before bed leads to better sleep.",
                      Q44_8_ithinkingworkingoutregularlyleadstobettersleep = "I think working out regularly leads to better sleep.",
                      Q44_9_ithinkmeditatingbeforesleephelpsquality = "I think meditating before bed helps sleep quality.", 
                      Q59_1_icanmaintainhealthysleephabits = "I can maintain healthy sleep habits.",
                      Q59_2_icancutoutscreenuseonehourbeforesleep = "I can cut out screen use 1 hour before bed.",
                      Q59_3_icanworkoutregularly = "I can work out regularly.",
                      Q59_4_icanmediatebeforebed = "I can meditate before bed.",
                      Q37_whatdoyouconsideragoodnightssleep = "What do you consider a good night's sleep?",
                      Q50_1_energyfordailyacitivites = "Energy for daily activities", 
                      Q50_2_attractivness = "Attractiveness (to self & others)",
                      Q50_3_productivity = "Productivity at work/school",
                      Q50_4_accomplishmentofotherdailygoals = "Accomplishment of other daily goals (e.g. exercise, cooking, paying bills, etc)",
                      Q50_5_mentalandemotionalwellbeing = "Mental and emotional wellbeing",
                      Q50_6_fosteringmaintaingrelationships = "Fostering/maintaining relationships",
                      Q50_7_caringforchildren = "Caring for children",
                      Q53_1_getoutsidefor10mininthemorning = "Get outside for 10 minutes in the morning." ,
                      Q53_2_exerciseduringtheday = "Exercise during the day.",
                      Q53_3_doingabreathingexercisebeforesleep = "Do a breathing exercise before you sleep.",
                      Q53_4_notusescreens = "Not use screens (i.e. cell phone, tablet, computer, television) for 1 hour before bed",
                      Q53_5_listeningtoacalmingaudiobookorpodcast = "Listen to a calming audiobook or podcast before bed",
                      information = "Where have you seen or received information about sleep quality or sleep hygiene?"
)
tab1 <- tableby(~ Q3_role + 
                  Q4_gender +
                  Q5_age +
                  Q6_numberinhousehold +
                  Q37_employed +
                  Q8_diagnosis +
                  Q10_workdayhoursofsleep +
                  Q11_weekendhoursofsleep +
                  Q9_howoftensleepy,
                data=sleephygiene, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab1, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
Overall (N=194)
What is your role at Bloomberg
   N-Miss 3
   Faculty/Staff Member 4 (2.1%)
   Full-time student 135 (70.7%)
   Part-time student 52 (27.2%)
What gender do you identify as?
   N-Miss 3
   Female 151 (79.1%)
   Male 35 (18.3%)
   Non-binary / third gender 4 (2.1%)
   Prefer not to say 1 (0.5%)
How old are you?
   Median (Q1, Q3) 28.00 (25.00, 32.00)
How many people live in your household, including yourself?
   Median (Q1, Q3) 2.00 (2.00, 3.00)
Are you currently employed outside of your education program?
   N-Miss 3
   No 95 (49.7%)
   Yes 96 (50.3%)
Have you ever been diagnosed with any of the following sleep disorders?
   N-Miss 3
   Insomnia 11 (5.8%)
   No 174 (91.1%)
   Other 2 (1.0%)
   Sleep Apnea 4 (2.1%)
During the past 5 workdays, how many hours of sleep did you get per night on average?
   Median (Q1, Q3) 7.00 (6.00, 7.50)
During the past weekend, how many hours of sleep did you get per night on average?
   Median (Q1, Q3) 8.00 (7.00, 9.00)
How often do you feel sleepy during the day?
   N-Miss 67
   Rarely 26 (20.5%)
   Sometimes 91 (71.7%)
   Very often 0 (0.0%)
   Always 10 (7.9%)
#If student
student <- sleephygiene %>% filter(Q3_role != "Faculty/Staff Member")

tab1 <- tableby(~ Q2_program,
                data=student, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab1, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
Overall (N=187)
What is your current program at Bloomberg?
   Doctoral Student 52 (27.8%)
   Masters Student 129 (69.0%)
   Other 1 (0.5%)
   Post doctoral student 5 (2.7%)
#If employed 
employed <- sleephygiene %>% filter(Q37_employed == "Yes")

tab1 <- tableby(~ Q38_wfh,
                data=employed, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab1, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
Overall (N=96)
Do you work from home?
   No 25 (26.0%)
   Yes 71 (74.0%)
#If wfh
notworkfromhome <- sleephygiene %>% filter(Q37_employed == "Yes" & Q38_wfh == "No")

tab1 <- tableby(~ Q39_dayornight,
                data=notworkfromhome, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab1, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
Overall (N=25)
Do you work day or night shifts?
   N-Miss 1
   Day shift 21 (87.5%)
   Night shift 3 (12.5%)
tab1 <- tableby(~ Q13_consistentwakeup + 
                  Q15_consistentbedtimeonweekdays +
                  Q49_sleepqualitychangecovid +
                  bedtimeroutine +
                  Q19_howmanyhourssdidyouuseascreen +
                  Q12_1_howmanynightsusescreen +
                  Q17_stressedaboutschool +
                  cantsleepfeeling +
                  Q18_howoftenpracticemindfullness +
                  behaviors +
                  Q44_1_thingsidointhelasthourbeforesleepaffectthequalityofmysleep +
                  Q44_2_gettingagoodnightssleepisimportantome +
                  Q44_3_mostofmyfriendshaveahealthysleeproutine +
                  Q44_4_lackofsleepaffectsmyacademicperformance +
                  Q44_5_havingaregularsleeproutineimprovesmentalclariy +
                  Q44_6_ifeelpositiveaboutthequalityofmysleep +
                  Q44_7_ithinkcuttingoutscreenuseonehourbeforesleepleadstobettersleep +
                  Q44_8_ithinkingworkingoutregularlyleadstobettersleep +
                  Q44_9_ithinkmeditatingbeforesleephelpsquality +
                  Q59_1_icanmaintainhealthysleephabits +
                  Q59_2_icancutoutscreenuseonehourbeforesleep +
                  Q59_3_icanworkoutregularly +
                  Q59_4_icanmediatebeforebed +
                  Q37_whatdoyouconsideragoodnightssleep +
                  Q50_1_energyfordailyacitivites +
                  Q50_2_attractivness +
                  Q50_3_productivity +
                  Q50_4_accomplishmentofotherdailygoals +
                  Q50_5_mentalandemotionalwellbeing +
                  Q50_6_fosteringmaintaingrelationships +
                  Q50_7_caringforchildren +
                  Q53_1_getoutsidefor10mininthemorning +
                  Q53_2_exerciseduringtheday +
                  Q53_3_doingabreathingexercisebeforesleep +
                  Q53_4_notusescreens +
                  Q53_5_listeningtoacalmingaudiobookorpodcast +
                  information,
                data=sleephygiene, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab1, title='Table 2. Sleep questions', pfootnote=TRUE, digits = 2)
Table 2. Sleep questions
Overall (N=194)
Do you have a consistent time you wake up on weekdays?
   N-Miss 164
   Rarely 0 (0.0%)
   Sometimes 30 (100.0%)
   Very often 0 (0.0%)
   Always 0 (0.0%)
Do you have a consistent time you wake up on weekdays?
   N-Miss 3
   No 77 (40.3%)
   Sometimes 46 (24.1%)
   Yes 68 (35.6%)
Has your sleep quality changed due to the COVID-19 pandemic?
   N-Miss 5
   No 70 (37.0%)
   Yes, I feel my sleep quality has improved 25 (13.2%)
   Yes, I feel my sleep quality has worsened 94 (49.7%)
My bedtime routine includes:
   N-Miss 4
   Brushing teeth 60 (31.6%)
   Phone usage 9 (4.7%)
   Reading 4 (2.1%)
   Showering 2 (1.1%)
   Washing my face 113 (59.5%)
   Watching TV 2 (1.1%)
How many hours per day do you typically use a screen? (i.e. cell phone, tablet, computer, television)
   N-Miss 5
   0 0 (0.0%)
   1 0 (0.0%)
   2 0 (0.0%)
   3 3 (1.6%)
   4 5 (2.6%)
   5 5 (2.6%)
   6 8 (4.2%)
   7 4 (2.1%)
   8 27 (14.3%)
   9 10 (5.3%)
   10 51 (27.0%)
   11 2 (1.1%)
   12 49 (25.9%)
   13 3 (1.6%)
   14 13 (6.9%)
   15 5 (2.6%)
   16 3 (1.6%)
   17 1 (0.5%)
In the past week, how many nights did you use screens (i.e. cell phone, tablet, computer, television) within 1 hour before bed?
   Median (Q1, Q3) 7.00 (7.00, 7.00)
How stressed do you currently feel about school?
   Median (Q1, Q3) 7.00 (6.00, 8.00)
When you can’t sleep do you feel
   N-Miss 3
   Angry 12 (6.3%)
   Frustrated 97 (50.8%)
   Guilty 31 (16.2%)
   None of the above 13 (6.8%)
   Other 9 (4.7%)
   Sad 6 (3.1%)
   Stressed 23 (12.0%)
How often do you practice mindfulness techniques? (i.e. breathing exercises, meditation, etc.,)
   N-Miss 52
   Rarely 71 (50.0%)
   Sometimes 66 (46.5%)
   Very often 0 (0.0%)
   Always 5 (3.5%)
Which of the following behaviors do you participate in?
   N-Miss 5
   Alcohol Consumption 88 (46.6%)
   Cigarette smoking 4 (2.1%)
   Daytime napping 1 (0.5%)
   Drinking Caffeinated beverages 3 (1.6%)
   Exercise 67 (35.4%)
   Social Media Use 26 (13.8%)
The things I do in the last hour before bed affect the quality of my sleep.
   N-Miss 3
   Strongly disagree 6 (3.1%)
   Somewhat disagree 15 (7.9%)
   Neither agree nor disagree 18 (9.4%)
   Somewhat agree 86 (45.0%)
   Strongly agree 66 (34.6%)
Getting a good night’s sleep is important to me.
   N-Miss 3
   Strongly disagree 1 (0.5%)
   Somewhat disagree 1 (0.5%)
   Neither agree nor disagree 4 (2.1%)
   Somewhat agree 29 (15.2%)
   Strongly agree 156 (81.7%)
Most of my friends have a healthy sleep routine.
   N-Miss 4
   Strongly disagree 9 (4.7%)
   Somewhat disagree 38 (20.0%)
   Neither agree nor disagree 92 (48.4%)
   Somewhat agree 39 (20.5%)
   Strongly agree 12 (6.3%)
Lack of sleep affects my academic performance.
   N-Miss 4
   Strongly disagree 3 (1.6%)
   Somewhat disagree 9 (4.7%)
   Neither agree nor disagree 14 (7.4%)
   Somewhat agree 75 (39.5%)
   Strongly agree 89 (46.8%)
Having a regular sleep routine improves mental clarity/sharpness.
   N-Miss 3
   Strongly disagree 0 (0.0%)
   Somewhat disagree 1 (0.5%)
   Neither agree nor disagree 10 (5.2%)
   Somewhat agree 51 (26.7%)
   Strongly agree 129 (67.5%)
I feel positive about the quality of my sleep.
   N-Miss 3
   Strongly disagree 22 (11.5%)
   Somewhat disagree 56 (29.3%)
   Neither agree nor disagree 32 (16.8%)
   Somewhat agree 62 (32.5%)
   Strongly agree 19 (9.9%)
I think cutting out screen use 1 hour before bed leads to better sleep.
   N-Miss 3
   Strongly disagree 7 (3.7%)
   Somewhat disagree 7 (3.7%)
   Neither agree nor disagree 35 (18.3%)
   Somewhat agree 82 (42.9%)
   Strongly agree 60 (31.4%)
I think working out regularly leads to better sleep.
   N-Miss 3
   Strongly disagree 0 (0.0%)
   Somewhat disagree 3 (1.6%)
   Neither agree nor disagree 17 (8.9%)
   Somewhat agree 54 (28.3%)
   Strongly agree 117 (61.3%)
I think meditating before bed helps sleep quality.
   N-Miss 4
   Strongly disagree 5 (2.6%)
   Somewhat disagree 11 (5.8%)
   Neither agree nor disagree 66 (34.7%)
   Somewhat agree 61 (32.1%)
   Strongly agree 47 (24.7%)
I can maintain healthy sleep habits.
   N-Miss 4
   Not at all confident 14 (7.4%)
   Slightly confident 27 (14.2%)
   Somewhat confident 62 (32.6%)
   Pretty confident 66 (34.7%)
   Extremely confident 21 (11.1%)
I can cut out screen use 1 hour before bed.
   N-Miss 4
   Not at all confident 42 (22.1%)
   Slightly confident 61 (32.1%)
   Somewhat confident 47 (24.7%)
   Pretty confident 25 (13.2%)
   Extremely confident 15 (7.9%)
I can work out regularly.
   N-Miss 5
   Not at all confident 14 (7.4%)
   Slightly confident 35 (18.5%)
   Somewhat confident 39 (20.6%)
   Pretty confident 48 (25.4%)
   Extremely confident 53 (28.0%)
I can meditate before bed.
   N-Miss 4
   Not at all confident 44 (23.2%)
   Slightly confident 48 (25.3%)
   Somewhat confident 51 (26.8%)
   Pretty confident 31 (16.3%)
   Extremely confident 16 (8.4%)
What do you consider a good night’s sleep?
   N-Miss 3
   10+ hours 1 (0.5%)
   7 hours 27 (14.1%)
   8 hours 134 (70.2%)
   9 hours 28 (14.7%)
   Less than or equal to 6 hours 1 (0.5%)
Energy for daily activities
   Median (Q1, Q3) 5.00 (4.00, 5.00)
Attractiveness (to self & others)
   Median (Q1, Q3) 3.00 (2.00, 4.00)
Productivity at work/school
   Median (Q1, Q3) 5.00 (4.00, 5.00)
Accomplishment of other daily goals (e.g. exercise, cooking, paying bills, etc)
   Median (Q1, Q3) 5.00 (4.00, 5.00)
Mental and emotional wellbeing
   Median (Q1, Q3) 5.00 (4.00, 5.00)
Fostering/maintaining relationships
   Median (Q1, Q3) 4.00 (3.00, 5.00)
Caring for children
   Median (Q1, Q3) 1.00 (1.00, 4.00)
Get outside for 10 minutes in the morning.
   Median (Q1, Q3) 4.00 (2.00, 5.00)
Exercise during the day.
   Median (Q1, Q3) 4.00 (3.00, 5.00)
Do a breathing exercise before you sleep.
   Median (Q1, Q3) 3.00 (2.00, 4.00)
Not use screens (i.e. cell phone, tablet, computer, television) for 1 hour before bed
   Median (Q1, Q3) 2.00 (2.00, 3.00)
Listen to a calming audiobook or podcast before bed
   Median (Q1, Q3) 3.00 (2.00, 4.00)
Where have you seen or received information about sleep quality or sleep hygiene?
   N-Miss 18
   Friends 6 (3.4%)
   Health care professional 63 (35.8%)
   News sources 12 (6.8%)
   Other online source 23 (13.1%)
   Social media 57 (32.4%)
   University wellbeing resources 15 (8.5%)
attach(sleephygiene)

Fig 1

ggplot(sleephygiene) + 
  geom_bar(aes(x=Q3_role), fill="navyblue") +
  #coord_flip() + 
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=32)) +
  labs(title = "Role") +
  xlab("")

Fig 2

ggplot(student) + 
  geom_bar(aes(x=Q2_program), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=32)) +
  labs(title = "What is your current program at Bloomberg?") +
  xlab("")

Fig 3

ggplot(student) + 
  geom_bar(aes(x=Q4_gender), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=32)) +
  labs(title = "What gender do you identify as?") +
  xlab("")

Fig 4

ggplot(student) + 
  geom_bar(aes(x=Q37_employed), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=32)) +
  labs(title = "Are you currently employed outside of your education program?") +
  xlab("")

Fig 5

ggplot(employed) + 
  geom_bar(aes(x=Q38_wfh), fill="navyblue") +
  coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=32)) +
  labs(title = "Do you work from home?") +
  xlab("")

Fig 6

ggplot(notworkfromhome) + 
  geom_bar(aes(x=Q39_dayornight), fill="navyblue") +
  coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=32)) +
  labs(title = "Do you work day or night shifts?") +
  xlab("")

Fig 7

ggplot(sleephygiene) + 
  geom_bar(aes(x=Q7_children), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=15)) +
  labs(title = "Are there children living in your household?") +
  xlab("")

Fig 8

ggplot(sleephygiene) + 
  geom_bar(aes(x=Q8_diagnosis), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=20), axis.text.x = element_text(size=32)) +
  labs(title = "Have you ever been diagnosed with any of the following sleep disorders?") +
  xlab("")

Fig 9

ggplot(sleephygiene) + 
  geom_bar(aes(x=Q9_howoftensleepy), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=32)) +
  labs(title = "How often do you feel sleepy during the day?") +
  xlab("")

Fig 10

ggplot(sleephygiene) + 
  geom_bar(aes(x=Q13_consistentwakeup), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=32)) +
  labs(title = "Do you have a consistent time you wake up on weekdays?") +
  xlab("")

Fig 11

ggplot(sleephygiene) + 
  geom_bar(aes(x=Q15_consistentbedtimeonweekdays), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Do you have a consistent bedtime on weekdays?") +
  xlab("")

Fig 12

ggplot(sleephygiene) + 
  geom_bar(aes(x=Q49_sleepqualitychangecovid), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Has your sleep quality changed due to the COVID-19 pandemic?") +
  xlab("")

Fig 13

ggplot(sleephygiene) + 
  geom_bar(aes(x=bedtimeroutine), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "My bedtime routine includes") +
  xlab("")

Fig 14

ggplot(sleephygiene) + 
  geom_bar(aes(x=Q17_stressedaboutschool), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "How stressed do you currently feel about school?") +
  xlab("")
## Warning: Removed 5 rows containing non-finite values (stat_count).

Fig 15

ggplot(sleephygiene) + 
  geom_bar(aes(x=cantsleepfeeling), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "When you can't sleep do you feel") +
  xlab("")

Fig 16

ggplot(sleephygiene) + 
  geom_bar(aes(x=Q18_howoftenpracticemindfullness), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "How often do you practice mindfulness techniques? (i.e. breathing exercises, meditation, etc.,") +
  xlab("")

Fig 17

ggplot(sleephygiene) + 
  geom_bar(aes(x=behaviors), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Which of the following behaviors do you participate in? Check all that apply. ") +
  xlab("")

Fig 18

ggplot(sleephygiene) + 
  geom_bar(aes(x=Q44_1_thingsidointhelasthourbeforesleepaffectthequalityofmysleep), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "The things I do in the last hour before bed affect the quality of my sleep.") +
  xlab("")

ggplot(sleephygiene) + 
  geom_bar(aes(x=Q44_2_gettingagoodnightssleepisimportantome), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Getting a good night's sleep is important to me.") +
  xlab("")

ggplot(sleephygiene) + 
  geom_bar(aes(x=Q44_3_mostofmyfriendshaveahealthysleeproutine), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Most of my friends have a healthy sleep routine.") +
  xlab("")

ggplot(sleephygiene) + 
  geom_bar(aes(x=Q44_4_lackofsleepaffectsmyacademicperformance), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Lack of sleep affects my academic performance.") +
  xlab("")

ggplot(sleephygiene) + 
  geom_bar(aes(x=Q44_5_havingaregularsleeproutineimprovesmentalclariy), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Having a regular sleep routine improves mental clarity/sharpness.") +
  xlab("")

ggplot(sleephygiene) + 
  geom_bar(aes(x=Q44_6_ifeelpositiveaboutthequalityofmysleep), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I feel positive about the quality of my sleep.") +
  xlab("")

ggplot(sleephygiene) + 
  geom_bar(aes(x=Q44_7_ithinkcuttingoutscreenuseonehourbeforesleepleadstobettersleep), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I think cutting out screen use 1 hour before bed leads to better sleep.") +
  xlab("")

ggplot(sleephygiene) + 
  geom_bar(aes(x=Q44_8_ithinkingworkingoutregularlyleadstobettersleep), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I think working out regularly leads to better sleep.") +
  xlab("")

ggplot(sleephygiene) + 
  geom_bar(aes(x=Q44_9_ithinkmeditatingbeforesleephelpsquality), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I think meditating before bed helps sleep quality.") +
  xlab("")

Fig 19

ggplot(sleephygiene) + 
  geom_bar(aes(x=Q59_1_icanmaintainhealthysleephabits), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I can maintain healthy sleep habits.") +
  xlab("")

ggplot(sleephygiene) + 
  geom_bar(aes(x=Q59_2_icancutoutscreenuseonehourbeforesleep), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I can cut out screen use 1 hour before bed.") +
  xlab("")

ggplot(sleephygiene) + 
  geom_bar(aes(x=Q59_3_icanworkoutregularly), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I can work out regularly.") +
  xlab("")

ggplot(sleephygiene) + 
  geom_bar(aes(x=Q59_4_icanmediatebeforebed), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I can meditate before bed.") +
  xlab("")

Fig 20

ggplot(sleephygiene) + 
  geom_bar(aes(x=Q50_1_energyfordailyacitivites), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Energy for daily activities") +
  xlab("")
## Warning: Removed 4 rows containing non-finite values (stat_count).

ggplot(sleephygiene) + 
  geom_bar(aes(x=Q50_2_attractivness), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Attractiveness (to self & others)") +
  xlab("")
## Warning: Removed 4 rows containing non-finite values (stat_count).

ggplot(sleephygiene) + 
  geom_bar(aes(x=Q50_3_productivity), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Productivity at work/school") +
  xlab("")
## Warning: Removed 4 rows containing non-finite values (stat_count).

ggplot(sleephygiene) + 
  geom_bar(aes(x=Q50_4_accomplishmentofotherdailygoals), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Accomplishment of other daily goals (e.g. exercise, cooking, paying bills, etc)") +
  xlab("")
## Warning: Removed 4 rows containing non-finite values (stat_count).

ggplot(sleephygiene) + 
  geom_bar(aes(x=Q50_5_mentalandemotionalwellbeing), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Mental and emotional wellbeing") +
  xlab("")
## Warning: Removed 5 rows containing non-finite values (stat_count).

ggplot(sleephygiene) + 
  geom_bar(aes(x=Q50_6_fosteringmaintaingrelationships), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Fostering/maintaining relationships") +
  xlab("")
## Warning: Removed 4 rows containing non-finite values (stat_count).

ggplot(sleephygiene) + 
  geom_bar(aes(x=Q50_7_caringforchildren), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Caring for children") +
  xlab("")
## Warning: Removed 11 rows containing non-finite values (stat_count).

Fig 21

ggplot(sleephygiene) + 
  geom_bar(aes(x=Q59_1_icanmaintainhealthysleephabits), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I can maintain healthy sleep habits.") +
  xlab("")

ggplot(sleephygiene) + 
  geom_bar(aes(x=Q59_2_icancutoutscreenuseonehourbeforesleep), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I can cut out screen use 1 hour before bed.") +
  xlab("")

ggplot(sleephygiene) + 
  geom_bar(aes(x=Q59_3_icanworkoutregularly), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I can work out regularly.") +
  xlab("")

ggplot(sleephygiene) + 
  geom_bar(aes(x=Q59_4_icanmediatebeforebed), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I can meditate before bed.") +
  xlab("")

Fig 22

ggplot(sleephygiene) + 
  geom_bar(aes(x=information), fill="navyblue") +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=20), axis.text.x = element_text(size=16)) +
  labs(title = "Where have you seen or received information about sleep quality or sleep hygiene? Check all that apply. ") +
  xlab("")